{template header}
<style type="text/css">
    .boardDiv, .tagDiv{margin-bottom: 10px;}
    .boardDiv, .tagDiv{clear: both;}
    .boardList, .tagList{margin: 10px auto;}
    .boardList li, .tagList li{list-style-type:none;float:left;margin:2px 9px;background-color:#dbeaf9;padding:5px;cursor:pointer;border-radius: 8px;}
    .tagList li{background-color: #CED7E0;}
    .boardList label, .tagList label{float: left;margin-bottom: 0;}
    .boardList label input, .tagList label input {float: left;margin-right: 5px;}
    a.btn-primary {margin-top: 3px;}
    #subButton {display: none;}
</style>

<h4 style="padding-left:10px;">
        <span>搜索</span>
        <i class="icon-search"></i>
</h4>

<form class="form-horizontal" method="post" action="">
    <div class="control-group search-group"style="margin:0;" >
        <label class="control-label" style="text-align:left; text-indent:12px; " >ID或标题或简介</label>
        <div class="controls">
          <input type="text" placeholder="设置后忽略其他项" name="title" value="{$search['title']}">
        </div>
    </div>
    <div class="control-group search-group"style="margin:0;" >
        <div class="controls">
            <input type="hidden" value="1" name="isSearch">
            <input type='hidden' value='1' name='p'>
            <input type='hidden' value='' name='order'>
            <button class="btn" type="submit">提交</button>　
            <button class="btn" type="reset">重置</button>
        </div>
    </div>
</form>

<div class="tagDiv">
  <ul id="tagList" class="tagList">
   <li><a href="index.php?c=admin&a=hotAns">全部</a>
   <li><a href="index.php?c=admin&a=hotAns&force=1">首页22（只能点默认、热门、精华排序）</a>
    {loop $tagList $k $v}
      <li data-value="{$v['tagId']}"><a href="index.php?c=admin&a=hotAns&tagId={$v['tagId']}">{$v['tagName']}</a></li>
    {/loop}
  </ul>
</div>
<div class="bs-docs-example pt-10" style="clear:both;">
    <table class="table table-striped t-width">
        <thead>
            <tr>
                <th><label for="selectAll"><input type="checkbox" id="selectAll"> aa发帖人</label></th>
                <th>标题</th>                
                <th>标签</th>
                <th>添加时间</th><th>最后更新</th><th>最后评论</th>
                <th><a class='order' data-order='comm'>总评论</a></th>
                <th><a class='order' data-order='like'>喜欢</a></th>
                <th>显示</th>
                <th><a class='order' data-order='hot'>首页热门</a></th>
                <th><a class='order' data-order='best'>精华</a></th>
                <th><a class='order' data-order='top'>置顶</a></th>               
              
                <th width="150">操作</th>
            </tr>
        </thead>
        <tbody>
            {loop $postList $k $v}
            <tr id="{$v['news_id']}">
                <td>
                    <label for="news_{$v['news_id']}">
                    <input type="checkbox" name="news_id[]" value="{$v['news_id']}" id="news_{$v['news_id']}">
                    <img width="50" src="{$v['header']}">{$v['nickname']}
                    </label>
                </td>
                <td>{$v['title']}</td>               
                <td>{loop $v['tag'] $kk $tag}<div id="{$tag['tagId']}">{$tag['tagName']}</div>{/loop}</td>
                <td>
                    {eval echo date('Y-m-d H:i:s', $v['real_addtime'])}
                </td>
                <td>
                    {eval echo date('Y-m-d H:i:s', $v['lastupdate'])}
                </td>
                <td>
                    {if $v['lastComment']}{eval echo date('Y-m-d H:i:s', $v['lastComment'])}{else}无评论{/if}
                </td>
                <td>{$v['total_comment']}</td>
                <td>{$v['loves']}</td>
                <td>{if $v['is_show'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['isHomeBest'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['isBest'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['is_top'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
               
                <td>
                    <a class="btn btn-primary" href="?c=admin&a=postInfo&action=edit&postId={$v['news_id']}">编辑</a>&nbsp;
                    <a class="btn btn-primary" href="?c=admin&a=commentList&news_id={$v['news_id']}">查看评论</a>&nbsp;
                    <a class="btn btn-primary" href="?c=admin&a=addNewsComment&news_id={$v['news_id']}">加评</a>&nbsp;
                </td>
            </tr>
            {/loop}
            <tr class="setTr">
                <td>
                    <select style="width:150px;" name="action" onchange="showSubButton(this.value)">
                        <option value="">想干什么……</option>
                        <!-- <option value="HomeHot">首页热门</option> -->
                        <!-- <option value="cancelHomeHot">取消首页热门</option> -->
                        <option value="HomeHot">增加热度</option>
                        <option value="cancelHomeHot">减少热度</option>
                        <option value="Best">加精</option>
                        <option value="cancelBest">减精</option>
                        <option value="Top">置顶</option>
                        <option value="cancelTop">取消置顶</option>
                    </select>
                </td>
                <td colspan="9"><span id="subButton"><input type="submit" class="btn" value="确定"></span></td>
            </tr>
        </tbody>
    </table>
</div>
<!-- </form> -->
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
<script type="text/javascript">

var bid = 2;
var tid = "{$tagId}";
bid = bid.toString();
if(tid > 0) {
    for(var i=0,e=$("#tagList>li");i<e.length;i++){
        if(e[i].getAttribute("data-value") == tid.toString()) {
            e[i].style.backgroundColor="yellow";
        }
    }
}
for(var i=0,e=$("#boardList>li");i<e.length;i++){
    if(e[i].getAttribute("data-value") == bid) {
        e[i].style.backgroundColor="yellow";
    }
}
$("input#selectAll").click(function(){
    var isChecked = $(this).prop("checked");
    for (var i=0,e=$("td :checkbox"); i<e.length; i++){
        $(e[i]).prop("checked",isChecked);
    }
    return;
});
$("span#subButton").click(function(e){
  $(this).prop("checked",false);
  var action = $("select[name='action']").val();

  var postId = '';
  var e = $("td :checkbox");
  for (var i=0,len=e.length; i<len; i++) {
    if(e[i].checked == true) {
        postId += e[i].value+',';
    }
  }
  if(postId == '') {
    alert('请选择最少一个帖子');
    $(this).prop("checked",true);
    return;
  }
  if(action == '') {
    alert('请选择操作类型');
    $(this).prop("checked",true);
    return;
  }
  $.ajax({url:"/adminajax/HotBestTop?postId="+postId+"&action="+action,               
          
          dataType:"json",
          error:function(){
              alert('未知错误');
              },
          success:function(data, status){
            turnData = eval(data);
            if(turnData.message == ''){
                var msg = ''
                for(var i=0; i<turnData.rel.length; i++){
                  val = turnData.rel[i];
                  msg += turnData.rel[i].pid+': '+ turnData.rel[i].suc + "\n";
                }
                alert(msg);
            }
            else
            {
              alert(turnData.message);
            }
            $("input#newTag").toggleClass("hide");
            $("span#subNewTag").toggleClass("hide");
          }
      });
   $(this).prop("checked",true);
  return true;
});

function showSubButton(type)
{
    if(type != '') {
        $("span#subButton").show();
    }
    else {
        $("span#subButton").hide();
    }
}
//热门，精华，置顶
$('.order').on('click',function(){
    var order=$(this).attr('data-order');
    //alert(order);
    $('[name=order').val(order);
    $('form').submit();
})

</script>
{template footer}
